package com.sz.stock.service;

import com.sz.stock.mapper.StockOhclMapper;
import com.sz.stock.model.StockOhcl;
import com.sz.stock.model.StockOhclExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class StockOhclServiceImpl implements IStockOhclService {
    @Autowired
    private StockOhclMapper stockOhclMapper;
    @Override
    public List<StockOhcl> getAll() {
        return stockOhclMapper.selectByExample(null);
    }

    @Override
    public StockOhcl getOne(String code) {
        StockOhclExample example = new StockOhclExample();
        StockOhclExample.Criteria criteria = example.createCriteria();
        criteria.andStockCodeEqualTo(code);
        List<StockOhcl> stockOhcls = stockOhclMapper.selectByExample(example);
        if(stockOhcls.size()!=0){
            return stockOhcls.get(0);
        }else{
            return null;
        }
    }

    @Override
    public Integer add(StockOhcl stockOhcl) {
        return stockOhclMapper.insertSelective(stockOhcl);
    }
}
